<?php


namespace common\models;


use Yii;
use yii\base\InvalidConfigException;
use yii\db\ActiveRecord;
use yii\redis\Connection;

class BaseModel extends ActiveRecord
{
	/**
	 * @var Connection $redis
	 */
	protected static $redis;

	/**
	 * 获取redis对象
	 * @return object
	 * @throws InvalidConfigException
	 */
	protected static function getRedis()
	{
		if (self::$redis instanceof Connection) {
			return self::$redis;
		}

		return Yii::$app->get('redis');
	}
}